<?php

/*

Snake Eyes (snakeeyes.php)

*/

$page_title = "Snake Eyes";
$rank_check = 1;
include "header.inc.php";

$getcode = fetch("SELECT * FROM snakeeyes2 WHERE user = '$userid' AND game = '$game'");
if (!$getcode[code])
{
	mysql_query("INSERT INTO snakeeyes2 (user,code,game) VALUES ('$userid','50','$game')");
	$getcode[code] = 50;
}

if ($act != "roll")
{
	echo $openHTML;
	echo "<p>Roll the dice to win points. Each roll costs 25 $pointsVar. Doubles are always worth 25 $pointsVar, see if you can find out what other rolls win.</p><p align=center>Predict the sum of the next roll.</p>

<form action=$base_url/snakeeyes.php?game=$game method=post>
<input type=hidden name=act value=roll>
<input type=hidden name=code value=$getcode[code]>

<CENTER><TABLE BGCOLOR=\"#000000\" CELLSPACING=1 CELLPADDING=0 WIDTH=300>
   <TR BGCOLOR=\"#009900\">
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/1.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/2.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/3.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/4.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/5.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/6.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
   </TR>
</TABLE>
<BR>
<TABLE CELLSPACING=1 CELLPADDING=0 WIDTH=300>
   <TR>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=1></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=2></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=3></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=4></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=5></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=6></B></CENTER>
      </TD>
   </TR>
</TABLE>
<BR>
<BR>
<TABLE BGCOLOR=\"#000000\" CELLSPACING=1 CELLPADDING=0 WIDTH=300>
   <TR BGCOLOR=\"#009900\">
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/8.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/9.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/10.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/11.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
      <TD HEIGHT=50>
         <CENTER><B><IMG SRC=\"images/games/snakeeyes/12.gif\" WIDTH=50 HEIGHT=50></B></CENTER>
      </TD>
   </TR>
</TABLE>
<BR>
<TABLE CELLSPACING=1 CELLPADDING=0 WIDTH=300>
   <TR>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=8></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=9></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=10></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=11></B></CENTER>
      </TD>
      <TD HEIGHT=20>
         <CENTER><B><INPUT TYPE=radio NAME=bet VALUE=12></B></CENTER>
      </TD>
   </TR>
</TABLE>
<p><input type=submit name=submit value=Roll!></p>
</CENTER>
</form>

<p>Note: You are not allowed to choose a 7 to be rolled, the fact that it doesn't show up IS NOT A BUG.</p>

$closeHTML";

}

if ($act == "roll")
{
	if ($points < 25)
	{
		die(header(error("snakeeyes.php?game=$game","You don't have enough points to play snake eyes.")));
	}
	if ($getcode[code] != $code)
	{
		die(header(error("snakeeyes.php?game=$game","Don't cheat.")));
	}
	$newcode = rand(1,1000);
	mysql_query("UPDATE snakeeyes2 SET code = '$newcode' WHERE user = '$userid' AND game = '$game'");
	$done = rand(1,6);
	$dtwo = rand(1,6);
	$dsum = $done + $dtwo;
	$odd = $bet % 2;
	if ($odd == 1)
	{
		if ($dsum == 7)
		{
			$prize = 25;
		}
		if ($done == $dtwo)
		{
			$prize = 25;
		}
		if ($dsum == $bet)
		{
			$prize = 100;
		}
	}
	if ($odd == 0)
	{
		if ($dsum == 7)
		{
			$prize = 25;
		}
		if ($done == $dtwo)
		{
			$prize = 25;
		}
		if ($dsum == $bet)
		{
			$prize = 75;
			if ($done == $dtwo)
			{
				$prize = 150;
			}
		}
	}
	if ($bet == 2)
	{
		if ($dsum == 7)
		{
			$prize = 25;
		}
		if ($done == $dtwo)
		{
			$prize = 25;
		}
		if ($dsum == 2)
		{
			$prize = 500;
		}
	}
	if (!$prize)
	{
		$prize = 0;
	}
	mysql_query("UPDATE members2 SET points=$points+$prize-25 WHERE id = '$userid' AND game = '$game'");
	echo $openHTML;

	echo "<p align=center>You bet that you would roll a $bet. The dice landed on ....</p>
	<p align=center><b><font size=+4 color=blue>$done</b></font> and <b><font size=+4 color=blue>$dtwo</b></font></p>
	<p align=center>You win $prize $pointsVar!</p>";

	echo "<form action=snakeeyes.php?game=$game method=post><p align=center><input type=submit name=submit value=\"Play Snakeeyes Again!\"></p></form>";

	echo $closeHTML;
}

?>